// packageB/pages/artList/artList.js
const app = getApp()
const font = require('../../../lib/js/font.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    height: app.globalData.height,
    titleBarHeight: app.globalData.titleBarHeight,
    // 组件所需的参数
    nvabarData: {
      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
      title: '精准定位选型', //导航栏 中间的标题
      color: "#2242A8",
      txtColor: '#FFFFFF'
    },
    isBrand: false,
    brandPic: "",
    brandName: "",
    isWater: false,
    waterPic: "",
    waterName: "",
    isTower: false,
    towerPic: "",
    towerName: "",
    isSubmit: false,
    attributeList: [
        {
          name : "定压补水",
          check: false,
        },
        {
          name : "加药",
          check: false,
        },
        {
          name : "软水",
          check: false,
        },
        {
          name : "水箱",
          check: false,
        },
        {
          name : "真空脱气机",
          check: false,
        },
      ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    font.loadFont(); //下载字体
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
     
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {
  //   let that = this;
  //   return {
  //     title: that.data.shareDetail.title,
  //     path: '/packageB/pages/artList/artList?share=true',
  //     imageUrl: that.data.shareDetail.icon,
  //     success: function (res) {
  //       wx.showToast({
  //         title: "已转发",
  //         icon: 'none',
  //         duration: 2000
  //       })
  //     }
  //   }
  // },
  showBrand(){
    this.setData({
      isBrand: true,
    })
  },
  closeShow(){
      this.setData({
        isBrand: false,
        isWater: false,
        isTower: false,
      })
  },
  choose(e){
    let that = this
    that.setData({
     brandPic: e.currentTarget.dataset.pic,
     brandName: e.currentTarget.dataset.name, 
     isBrand: false,
    })
    if(that.data.brandName&&that.data.waterName&&that.data.towerName){
      that.setData({
        isSubmit:true
      })
    }
  },
  showWater(){
    this.setData({
      isWater: true,
    })
  },
  chooseWater(e){
    let that = this
    that.setData({
     waterPic: e.currentTarget.dataset.pic,
     waterName: e.currentTarget.dataset.name, 
     isWater: false,
    })
    if(that.data.brandName&&that.data.waterName&&that.data.towerName){
      that.setData({
        isSubmit:true
      })
    }
  },
  showTower(){
    this.setData({
      isTower: true,
    })
  },
  chooseTower(e){
    let that = this
    that.setData({
     towerPic: e.currentTarget.dataset.pic,
     towerName: e.currentTarget.dataset.name, 
     isTower: false,
    })
    if(that.data.brandName&&that.data.waterName&&that.data.towerName){
      that.setData({
        isSubmit:true
      })
    }
  },
  chooseFality(e){
     let that = this
     let index = e.currentTarget.dataset.index
     if(that.data.attributeList[index].check){
      that.data.attributeList[index].check = false
     }else{
      that.data.attributeList[index].check = true
     }
     that.setData({
       attributeList: that.data.attributeList
     })
  },
  saveData(){
    wx.showToast({
      title: '提交成功',
      icon: 'none',
      duration: 2000
    })
  },
})